#include <Servo.h>

byte startByte;
int angle1;
int angle2;
int servo1pin = 9; // use a PWM pin
int servo2pin = 10; // use a PWM pin
int userInput[2] = {10, 10};
Servo servo1;
Servo servo2;

void setup()
{
  Serial.begin(9600); // init serial
  servo1.attach(servo1pin); // init servo
  servo2.attach(servo2pin); // init servo
}

void loop()
{
  if (Serial.available() > 2) { // if we have enough data to start with
      
    startByte = Serial.read();  // we can start 'consuming' the buffer
       if (startByte == 1) {  // check if we get the right sequence of data
         for (int i=0; i<2; i++) {  
           userInput[i] = Serial.read();  // now we read the data and make it re-usable
         }  
       
         servo1.write(userInput[0]);  // so we can send it to the servo...
         //Serial.write(userInput[0]);      // ...or back to the serial connection, perhaps for debugging
       }
       else if (startByte == 2) 
       {
         for (int i=0; i<2; i++) {  
           userInput[i] = Serial.read();  // now we read the data and make it re-usable
         }  
         servo2.write(userInput[1]);  
         //Serial.write(userInput[1]);
      }
    
    delay(50);
  }
}

